/**
 * @description 所以一个问卷的所有答卷列表如
 */

const mock = require('mockjs')
const Random = mock.Random
const getComponentList = require('./getComponentList')

function getStateList(len = 10) {
  const componentList = getComponentList()
  const arr = []
  for (let i = 0; i < len; i++) {
    const obj = {
      _id: Random.id()
    }
    componentList.forEach((item, index) => {
      switch (item.type) {
        case 'questionInput':
          obj[item.fe_id] = Random.ctitle()
          break
        case 'questionTextarea':
          obj[item.fe_id] = Random.csentence(5, 20)
          break
        case 'questionTitle':
          obj[item.fe_id] = Random.ctitle()
          break  
        case 'questionParagraph':
          obj[item.fe_id] = Random.csentence(5, 20)
          break 
        case 'questionInfo':
          obj[item.fe_id] = [Random.ctitle(),Random.csentence(5, 20)].join('|')
          break     
        case 'questionRadio':
          obj[item.fe_id] = item.props.options[Random.integer(0, 2)].text
          break
        case 'questionCheck':
          obj[item.fe_id] = `${item.props.options[Random.integer(0, 1)].label},${item.props.options[2].label}`
          break
      }
    })
    arr.push(obj)
  }
  return arr
}

module.exports = getStateList
